'use strict';
const cheerio = require('cheerio');
module.exports = {
  handleData(data) {
    const $ = cheerio.load(data);
    const resultArr = [];
    $('.job-primary').each(function () {
      const obj = {};
      obj.jobName = $(this).find('.job-title').text();
      obj.salary = $(this).find('.red').text();
      obj.desc = $(this).children('.info-primary').children('.name').next('p').text();
      obj.company = {};
      obj.company.name = $(this).children('.info-company').find('.name').text();
      obj.company.desc = $(this).children('.info-company').find('.name').next('p').text();
      resultArr.push(obj);
    });
    return resultArr;
  },

  formatStatus(trade_state) {
    switch (trade_state) {
      case 'CLOSED':
        return "7";
      case 'NOTPAY':
        return "1";
      case 'SUCCESS':
        return "2";
      case 'REFUND':
        return "5";
      default:
        return "-1";
    }
  },
};
